// #define print(...)
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
    ListNode *pn=head, *pd=head, *pre=NULL;
    for(int i=0; i<n; i++)
        pn = pn->next;
    while(pn){
        pn = pn->next;
        pre = pd;
        pd = pd->next;
    }
    if(pre && pre->next)
        pre->next = pre->next->next;
    print("delete ", pd->val, ", set ", pd->val = -1, "\n")
    return pd != head ? head : head->next;
}
};
